﻿using System;
using System.Collections.Generic;
using System.Text;
using System.Data;
using System.Data.OleDb;
using TableDataSet;

namespace Util
{
    class classDetailDA
    {
        static OleDbConnection connection;
        private OleDbDataAdapter adapter;

        public classDetailDS searchAllClass()
        {
            try
            {
                using (connection = new DBUtil().getOleConnection())
                {
                    adapter = new OleDbDataAdapter();
                    adapter.SelectCommand = connection.CreateCommand();
                    adapter.SelectCommand.CommandText = "select * from class_detail";

                    classDetailDS classDS = new classDetailDS();
                    adapter.Fill(classDS, "class_detail");

                    return classDS;
                }
            }
            catch (Exception e)
            {

            }
            return null;
        }

        public classDetailDS searchClassByID(int class_id)
        {
            try
            {
                using (connection = new DBUtil().getOleConnection())
                {
                    adapter = new OleDbDataAdapter();
                    adapter.SelectCommand = connection.CreateCommand();
                    adapter.SelectCommand.CommandText = "select * from class_detail where class_id = " + class_id.ToString();

                    classDetailDS classDS = new classDetailDS();
                    adapter.Fill(classDS, "class_detail");

                    return classDS;
                }
            }
            catch (Exception e)
            {

            }
            return null;
        }
    }
}
